#!/bin/bash -eux

if [[ $UPDATE  =~ true || $UPDATE =~ 1 || $UPDATE =~ yes ]]; then
    echo "==> Change to 163 YUM source"
	curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
    echo "==> Applying updates"
    yum -y update
    echo "==> Install gcc kernel-devel bzip2"
    yum install -y gcc kernel-devel bzip2

    # reboot
    echo "Rebooting the machine..."
    reboot
    sleep 60
fi
